package com.wanxi.util;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;

public class Tool {
    public static String nullToStr(String value) {
        return value == null ? "" : value;
    }

    public static Integer nullToInt(String value) {
        try {
            return Integer.parseInt(value);
        } catch (Exception e) {
            return -1;
        }

    }

    public static Integer nullToPage(String value) {
        try {
            return Integer.parseInt(value);
        } catch (Exception e) {
            return 1;
        }

    }

    public static Integer nullToLimit(String value) {
        try {
            return Integer.parseInt(value);
        } catch (Exception e) {
            return 10;
        }

    }

    public static BigDecimal nullToDecimal(String value) {
        try {
            return new BigDecimal(value);
        } catch (Exception e) {
            return new BigDecimal(-1);
        }

    }

    public static void main(String[] args) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("");

    }

    public static String nullToDate(String value) {

        return value == null || "".equals(value) ? "1111-01-01" : value;
    }
}
